<include file="header" />
    <div class="wraper show-search" js="wapjs/meeting/js/choiceuser">
        <div class="head clearfix">
            <a href="javascript:void(0);" id="back" data-href="javascript:history.back(-1)" class="iconfont icon-zuo"></a>
            <span class="head-name">选择参会人员</span>
        </div>

        <div class="search">
            <p class="tips-text text-gray text-center"><span class='iconfont icon-sousuo'></span>搜索名字、拼音、手机号</p>
            <input class="search-input" name="search" value=""/>
        </div>

        <div class="lists notopblock">
            <div class="fullbox">
                <div class="level-box">
                    <a href="#" class="level" id="level-1">{BEESCRM:$accountInfo['account_name']}</a>
                    <foreach name="departmentPath" item="vo">
                        <a href="BEESCRM:$vo.href}" class="level" id="level-2"><span class="iconfont icon-you" ></span> {BEESCRM:$vo.department_name}</a>
                    </foreach>
                </div>
            </div>
        </div>

        <div class="lists">
            <div class="list-line">
                <span class="iconfont icon-xuanze" id="select-all"></span> 全选
            </div>
        </div>
        <div class="lists" id="list">
            <foreach name="data" item="vo">
                <div class="list-line tb-mode">
                    <div class="tb-cell check-box" data-id="{BEESCRM:$vo.user_id}"><span class="iconfont icon-xuanze" v="{BEESCRM:$vo.user_id}"></span></div>
                    <div class="tb-cell small-photo"><img src="<if condition="!empty($vo['avatar'])">{BEESCRM:$vo.avatar}<else/>/assets/meeting/images/photo.jpg</if>"/></div>
                    <div class="tb-cell">{BEESCRM:$vo.real_name}</div>
                </div>
            </foreach>
        </div>
        <div class="fixed-total">
            <div class="tb-mode">
                <input type="hidden" value="{BEESCRM:$edit}" id="edit">
                <div class="tb-cell"><a href="#" class="btn pull-right bg-green sure">确定</a></div>
            </div>
        </div>
    </div>

    <div class="search-result">
    </div>
<input type="hidden" name="departmentId" id="departmentId" value="{BEESCRM:$departmentId}" />
<script type="text/javascript" src="/assets/public/seajs/sea.js"></script>
<script enter="publicjs/public" id="confnode" async="async" src="/assets/public/config.js"></script>
<script type="text/javascript" src="/assets/public/jquery-2.1.0.min.js"></script>
<script>
    $(document).on('blur','.search-input',function() {
        var data = {};
        data.department_id = $("#departmentId").val();
        data.search_content = $("input[name=search]").val();
        $.ajax({
            url : "/meeting/InviteUser/choiceUserPageSearch/account_id/"+"{BEESCRM:$accountId}",
            data : data,
            type : 'post',
            success : function(result){
                result = JSON.parse(result);
                if(result.status == 'S'){
                    //$('body').html('');
                    $('.show-search').css('display','none');
                    $('.search-result').html(result.message);
                }else{
                    fm.alert('操作失败');
                }
            }
        });
    })

    $(document).on('click',"#back",function() {
        var edit = $('#edit').val();
        url ="/Meeting/MeetingInvite/addInviteMeeting/step/two/";
        if(edit == 1){
            url ="/Meeting/MeetingInvite/editInviteMeeting/step/two/";
        }
        var users = $('#list .icon-xuanze1');
        var user_ids = {};
        for (var i = 0; i < users.length; i++) {
            user_ids[i] = parseInt($('#list .icon-xuanze1:eq('+i+')').attr('v'));
        }
        var data = {users:JSON.stringify(user_ids)};
        var jump = $(this).data('href');
        $.ajax({
            url:"/Meeting/MeetingInvite/saveByUser",
            data:data,
            type:'post',
            success:function(result){
                if(result){
                    location.href = jump;
                }else{
                    fm.alert('操作失败');
                }
            }
        });
    })

</script>
<include file="footer" />